package com.timous.动态规划;

import java.util.Arrays;
/**
 * https://leetcode-cn.com/problems/assign-cookies/
 * @author Timous
 * @create 2020-12-25 20:26
 **/
public class _455_分发饼干 {
    public int findContentChildren(int[] g, int[] s) {
        //g[i] 是胃口值
        //s[i] 是饼干量
        int j = 0;
        if (s.length == 0 || g.length == 0){
            return 0;
        }
        Arrays.sort(g);
        Arrays.sort(s);
        for (int i = 0; i < s.length; i++) {
            if (j < s.length){
                if (s[i] >= g[j]){
                    j++;
                }
            }
        }
        return j;
    }
}
